<% layout('/layouts/default.html', {title: '扣车原因管理', libs: ['validate']}){ %>
<div class="main-content">
	<div class="box box-main">
		<div class="box-header with-border">
			<div class="box-title">
				<i class="fa icon-note"></i> ${text(tblZdKcyy.isNewRecord ? '新增扣车原因' : '编辑扣车原因')}
			</div>
			<div class="box-tools pull-right">
				<button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>
			</div>
		</div>
		<#form:form id="inputForm" model="${tblZdKcyy}" action="${ctx}/tbl/kclb/tblZdKcyy/save" method="post" class="form-horizontal">
			<div class="box-body">
				<div class="form-unit">${text('基本信息')}</div>
				<div class="row">
					<#form:hidden path="recId"/>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required ">*</span> ${text('扣车类别编码')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:hidden path="kclbName" />
								<#form:select path="kclbCode" items="${kclbList}" itemLabel="kclbName" itemValue="kclbCode" class="form-control required" onChange="selChange()"/>
							</div>
						</div>
					</div>
					<!-- <div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required ">*</span> ${text('扣车类别')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="kclbName" maxlength="50" class="form-control required"/>
							</div>
						</div>
					</div> -->
					
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required ">*</span> ${text('扣车原因编码')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="faultCode" maxlength="10" class="form-control required"/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required ">*</span> ${text('扣车原因')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="faultName" maxlength="50" class="form-control required"/>
							</div>
						</div>
					</div>
				</div>
			</div>
			<div class="box-footer">
				<div class="row">
					<div class="col-sm-offset-2 col-sm-10">
						<button type="submit" class="btn btn-sm btn-primary" id="btnSubmit"><i class="fa fa-check"></i> ${text('保 存')}</button>&nbsp;
						
						<button type="button" class="btn btn-sm btn-default" id="btnCancel" onclick="js.closeCurrentTabPage()"><i class="fa fa-reply-all"></i> ${text('关 闭')}</button>
					</div>
				</div>
			</div>
		</#form:form>
	</div>
</div>
<% } %>
<script>
$("#inputForm").validate({
	submitHandler: function(form){
		//判断扣车原因编码前两位是否等于扣车类别编码，不等报错
		var yyCode = $("#kclbCode").val();
		var faultCode = $("#faultCode").val();
		if(faultCode.substring(0,2) != yyCode){
			js.showMessage("输入扣车原因编码前两位与扣车类别不一致，请确认！","","error",4000);
			return;
		}
		js.ajaxSubmitForm($(form), function(data){
			js.showMessage(data.message);
			if(data.result == Global.TRUE){
				js.closeCurrentTabPage(function(contentWindow){
					contentWindow.page();
				});
			}
		}, "json");
    }
});

function selChange(){
	var kclbName = $("#kclbCode").find("option:selected").text();
	$("#kclbName").val(kclbName);
	$("#faultCode").val($("#kclbCode").val());
}
</script>